package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitBusQrCode;
import com.ruoyi.bus.service.IWitBusQrCodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆二维码Controller
 * 
 * @author caiyanshan
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/bus/buscode")
public class WitBusQrCodeController extends BaseController
{
    @Autowired
    private IWitBusQrCodeService witBusQrCodeService;

    /**
     * 查询车辆二维码列表
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitBusQrCode witBusQrCode)
    {
        startPage();
        List<WitBusQrCode> list = witBusQrCodeService.selectWitBusQrCodeList(witBusQrCode);
        return getDataTable(list);
    }

    /**
     * 导出车辆二维码列表
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:export')")
    @Log(title = "车辆二维码", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitBusQrCode witBusQrCode)
    {
        List<WitBusQrCode> list = witBusQrCodeService.selectWitBusQrCodeList(witBusQrCode);
        ExcelUtil<WitBusQrCode> util = new ExcelUtil<WitBusQrCode>(WitBusQrCode.class);
        return util.exportExcel(list, "buscode");
    }

    /**
     * 获取车辆二维码详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:query')")
    @GetMapping(value = "/{routeQrId}")
    public AjaxResult getInfo(@PathVariable("routeQrId") Long routeQrId)
    {
        return AjaxResult.success(witBusQrCodeService.selectWitBusQrCodeById(routeQrId));
    }

    /**
     * 新增车辆二维码
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:add')")
    @Log(title = "车辆二维码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitBusQrCode witBusQrCode)
    {
        return toAjax(witBusQrCodeService.insertWitBusQrCode(witBusQrCode));
    }

    /**
     * 修改车辆二维码
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:edit')")
    @Log(title = "车辆二维码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitBusQrCode witBusQrCode)
    {
        return toAjax(witBusQrCodeService.updateWitBusQrCode(witBusQrCode));
    }

    /**
     * 删除车辆二维码
     */
    @PreAuthorize("@ss.hasPermi('bus:buscode:remove')")
    @Log(title = "车辆二维码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeQrIds}")
    public AjaxResult remove(@PathVariable Long[] routeQrIds)
    {
        return toAjax(witBusQrCodeService.deleteWitBusQrCodeByIds(routeQrIds));
    }
}
